@using CodeGenerator
@using RazorLight
@using BXJG.Common;
@using BXJG.Common.Extensions;
@inherits TemplatePage<ExecuteContext>
@{
    DisableEncoding = true;//禁止html编码，因为我们是做代码生成器
}
@("@using") @Model.Model.ApplicationShareNamespace
@@using BXJG.Utils.Application.Share.GeneralTree
@@using Microsoft.AspNetCore.Components.Sections

@@inherits TreeCreateBaseComponent<@Model.Model.DtoName, @Model.Model.CreateDtoName>

<SectionContent SectionName=@@($"{Master}-create-body")>
    <Form @@ref="frm" ValidateOnChange="true" Model="createDto" LabelColSpan="5" WrapperColSpan="19" OnFinish="OnFinish" Loading="IsBusy">
        <FormItem>
            <Input @@bind-Value="context.DisplayName" AllowClear="true" />
        </FormItem>
@foreach(var field in Model.Model.NormalFields)
{
    if(field.CSharpType == "bool"){
        <FormItem Label="@field.DisplayName">
            <Switch @@bind-Checked="context.@field.Name" />
        </FormItem>
    }
    else if(field.CSharpTypeIsNumber){
        <FormItem>
            <AntDesign.InputNumber @@bind-Value="context.@field.Name"
                                @if(field.NumberPrecision.HasValue){
                                    @:Precision="@field.NumberPrecision"
                                }
                                @if(field.NumberMax.HasValue){
                                    @:Max="@(field.NumberMaxSymbol)"
                                }
                                @if(field.NumberMin.HasValue){
                                    @:Min="@(field.NumberMinSymbol)"
                                }/>
        </FormItem>
    }
    else if(field.CSharpTypeIsDateTime){
        <FormItem>
            <AntDesign.DatePicker @@bind-Value="context.@field.Name"  AllowClear="true"/>
        </FormItem>
    }
    else{    
        <FormItem>
            <Input @@bind-Value="context.@field.Name"  AllowClear="true" />
        </FormItem>
    }
}
    </Form>
</SectionContent>

<SectionContent SectionName=@@($"{Master}-create-btns")>
    <Checkbox @@bind-Checked="isSaveAndContinue">保存后继续新增</Checkbox>
    <Button OnClick="BtnResetClick" Icon="@@IconType.Outline.Redo" Loading="isReseting" Disabled="IsBusy">重置</Button>
    <Button OnClick="BtnSaveClick" Icon="@@IconType.Outline.Save" Loading="isSaving" Disabled="IsBusy" Type="@@ButtonType.Primary" >保存</Button>
</SectionContent>